Dart BigInt operator ==
Syntax & Examples


BigInt.operator == operator

The `operator ==` in Dart checks for equality between two objects.


Syntax of BigInt.operator ==

The syntax of BigInt.operator == operator is:

operator ==(dynamic other) → bool

This operator == operator of BigInt the equality operator.

Parameters

ParameterOptional/RequiredDescription
otherrequiredthe object to compare for equality


✐ Examples

1 Check equality of strings

In this example,

  1. We create two string variables, str1 and str2, with the same value 'Hello'.
  2. We use the == operator to check if str1 is equal to str2.
  3. We print the result of the comparison to standard output.

Dart Program

void main() {
  String str1 = 'Hello';
  String str2 = 'Hello';
  bool isEqual = str1 == str2;
  print('Are str1 and str2 equal? $isEqual');
}

Output

Are str1 and str2 equal? true

2 Check equality of integers

In this example,

  1. We create two integer variables, num1 and num2, with different values.
  2. We use the == operator to check if num1 is equal to num2.
  3. We print the result of the comparison to standard output.

Dart Program

void main() {
  int num1 = 5;
  int num2 = 10;
  bool isEqual = num1 == num2;
  print('Are num1 and num2 equal? $isEqual');
}

Output

Are num1 and num2 equal? false

3 Check equality of lists

In this example,

  1. We create two list variables, list1 and list2, with the same contents.
  2. We use the == operator to check if list1 is equal to list2.
  3. We print the result of the comparison to standard output.

Dart Program

void main() {
  List<int> list1 = [1, 2, 3];
  List<int> list2 = [1, 2, 3];
  bool isEqual = list1 == list2;
  print('Are list1 and list2 equal? $isEqual');
}

Output

Are list1 and list2 equal? true

Summary

In this Dart tutorial, we learned about operator == operator of BigInt: the syntax and few working examples with output and detailed explanation for each example.